#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
因式分解示例
"""

from mcp.client.stdio import stdio_client
import asyncio

async def main():
    # 连接MCP服务
    client = await stdio_client()
    
    # 调用因式分解
    result = await client.call_tool("factorize", {"n": 36})
    print(f"36的因数分解: {result}")
    
    # 大数分解
    result = await client.call_tool("factorize", {"n": 123456})
    print(f"123456的因数分解: {result}")
    
    # 测试异常情况
    try:
        await client.call_tool("factorize", {"n": -5})
    except Exception as e:
        print(f"-5的因数分解错误: {str(e)}")

if __name__ == "__main__":
    asyncio.run(main())